<template>
  <div>
    <el-dialog
      :close-on-click-modal="false"
      :beforeClose="handleClose6"
      title="取消排货"
      :visible.sync="dialogVisible6"
      width="500px">
      <el-form :model="cancelForm" size="mini" label-width="100px"  ref="cancelForm" :rules="rules6">
        <el-form-item label="取消类型：" prop="cancelType">
          <el-radio-group v-model="cancelForm.cancelType">
            <el-radio label="物流"></el-radio>
            <el-radio label="销售"></el-radio>
            <el-radio label="采购"></el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="运费损失：" >
          <el-input-number v-model="cancelForm.lossFreight"></el-input-number>
        </el-form-item>
        <el-form-item label="取消原因：" prop="cancelReason">
          <el-input :autosize="{ minRows: 2, maxRows: 6}" type="textarea" v-model.trim="cancelForm.cancelReason"></el-input>
        </el-form-item>

      </el-form>
      <span slot="footer" class="dialog-footer">
            <el-button @click="handleClose6">取 消</el-button>
            <el-button type="primary" @click="handleConfirm6" :loading="btnLoading6">确 定</el-button>
        </span>
    </el-dialog>
  </div>
</template>
<script>
import "@/utils/jQuery.print"
import {cancelGoodsPlan} from "@/api/order"
const defaultCancelForm={
  billId:'',
  cancelType : "", //取消类型
  "cancelReason" : "", //取消原因
  "lossFreight" : 0 ,//损失运费
}
export default {
  name: "cancelShipment",
  data(){
    return {
      btnLoading6:false,
      dialogVisible6:false,
      cancelForm:JSON.parse(JSON.stringify(defaultCancelForm)),
      rules6:{
        cancelType:[{required: true, trigger: 'blur' ,message: '此项必填',}],
        cancelReason:[{required: true, trigger: 'blur' ,message: '此项必填',}],
      },
      billId:''

    }
  },

  filters:{

  },

  created() {

  },

  methods:{

    showCancelForm(billId){
      console.log("billId",billId)
      this.dialogVisible6 = true;
      this.cancelForm = JSON.parse(JSON.stringify(defaultCancelForm))
      this.billId = billId;
      console.log("this.billId",this.billId)
    },
    handleClose6(){
      this.dialogVisible6 = false;
    },
    handleConfirm6(){
      this.$refs.cancelForm.validate((valid) => {
        if (valid) {
          this.btnLoading6 = false;
          let data = JSON.parse(JSON.stringify(this.cancelForm));
          data.billId = this.billId;
          console.log("Data",data)
          cancelGoodsPlan(data).then(response => {
            this.btnLoading6 = false;
            this.$message({
              message: '提交成功',
              type: 'success',
              duration: 1000
            });
            this.handleClose6();
            this.$emit('refresh',this.billId)
          }).catch(() => {
            this.btnLoading6 = false;
          })
        }
      })
    },
  },
}
</script>

<style scoped lang="scss">
    .chexing-con{
      .chexing-title{
          font-weight: bold;
          font-size:14px;
          margin-bottom:10px;
      }
      .chexing-item-list{
        overflow: hidden;
        .chexing-item{
          display: inline-block;
          width:80px;
          height:30px;
          line-height: 30px;
          background: #eee;
          text-align: center;
          color:#666;
          margin-right:10px;
          margin-bottom:10px;
          cursor: pointer;
        }
        .chexing-item.choose{
          background: #f56c6c;
          color:#fff
        }

      }
    }
</style>
